< previous page page_103 next page >

Page 103
e10a6a0a59f035e870d90cca05b85fce.gif
    ByVal wStartIndex As Long, ByVal wNumEntries As Long, _
    lpPaletteEntries As PALETTEENTRY) As Long
Example program GetEntry, shown in Figure 3.9, uses the following code to retrieve the definitions of the colors in the logical palette used by a picture. It displays the colors' red, green, and blue components in the text box txtColors.
e10a6a0a59f035e870d90cca05b85fce.gif
' Display a list of the colors in the logical palette.
Private Sub ShowEntries()
Dim num_entries As Integer
Dim palentry(0 To 255) As PALETTEENTRY
Dim i As Integer
Dim txt As String

    If picCanvas.Picture = 0 Then
        txtColors.Text = "No picture loaded."
        Exit Sub
    ElseIf picCanvas.Picture.hPal = 0 Then
        txtColors.Text = "Default palette."
        Exit Sub
    End If

    num_entries = GetPaletteEntries( _
        picCanvas.Picture.hPal, 0, 256, palentry(0))

    txt = "  #  Red Green Blue" & vbCrLf
    For i = 0 To num_entries - 1
        txt = txt & _
            Format$(i, "@@@") & ":" & _
            Format$(palentry(i).peRed, "@@@@") & _
            Format$(palentry(i).peGreen, "@@@@@@") & _
            Format$(palentry(i).peBlue, "@@@@@") & _
0103-01.jpg
Figure 3.9
Example program GetEntry shows the color components of a picture's color palette.

 
< previous page page_103 next page >